package com.akeil.flash.action;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import com.akeil.flash.dataprocessing.IConstantProcessor;
import com.akeil.flash.model.EDeviceStatusType;

import flash.Activator;
import flash.Application;

public class StopTestAction extends AbstractFlashAction {

	public StopTestAction() {
		this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
				Activator.PLUGIN_ID, "icons/toolbar/stop_32px.png"));
		this.setToolTipText(resourceBundle.getString("toolbar.stop.test.tooltip"));
		this.setText(resourceBundle.getString("toolbar.stop.test.name"));
	}

	@Override
	public void run() {
		boolean b = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "提示", "是否取消本次试验?");
		if(b){
			Application.processor.sendCommand((byte)IConstantProcessor.CancelFX);
			Application.flashData.setStatus(EDeviceStatusType.FINISH);
			Application.flashData.setReceived(false);
			Application.resultView.stopTest();
		}
		super.run();
	}

}
